import request from "@/utils/request";
import Qs from "qs";

/**
 * 通过类型查询字典数据
 * @param {*} data 检索参数
 */
// data = 'advert_send_type'
// data = 'advert_content'
export function queryByType(data) {
  // advert_time_scale
  return request({
    url: "/sys/dict/data/queryByType",
    method: "get",
    params: {
      type: data,
    },
  });
}

/**
 * 查询字典数据列表
 * @param {*} data 检索参数
 */
export function list(data) {
  return request({
    url: "/sys/dict/data/list",
    method: "get",
    params: data,
  });
}

/**
 * 查询字典数据创建人列表
 */
export function listCreateBy() {
  return request({
    url: "/sys/dict/data/listCreateBy",
    method: "get",
  });
}

/**
 * 通过id查询字典数据
 */
export function queryById(data) {
  return request({
    url: "/sys/dict/data/queryById",
    method: "get",
    params: {
      dictDataId: data,
    },
  });
}

/**
 * 修改字典数据
 * @param {*} data 字典数据
 */
export function change(data) {
  return request({
    url: "/sys/dict/data/change",
    method: "put",
    data,
  });
}

/**
 * 添加字典数据
 * @param {*} data 字典数据
 */
export function create(data) {
  return request({
    url: "/sys/dict/data/create",
    method: "post",
    data,
  });
}

/**
 * 删除字典类型
 * @param {array} data 字典类型id
 */
export function deleteByIds(data) {
  return request({
    url: "/sys/dict/data/deleteByIds",
    method: "delete",
    params: {
      dictDataIds: data,
    },
    paramsSerializer: (params) => {
      return Qs.stringify(params, { indices: false });
    },
  });
}
